using System;
using System.Xml;

namespace ORT
{
	public class ObjectRecognitionTable
    {
		public static float checkNoTime = 2f;

		public static float uiScale = 1f;

		

		public static bool checkTouch = false;

		public static bool outputlog = false;

		public static bool maxangle = false;

		public static bool time = true;

		public static string tempP = "";

		public static float maxRadius = 0f;

		public static float minRadius = 0f;

		public static float trueRadius = 0f;

		public static float[] angleA1;

		public static float[] angleA2;

		public static float[] angleB1;

		public static float[] angleB2;

		public static float[] angleC1;

		public static float[] angleC2;

		public static int[] circleID;

		public static float[] specialAngle;

		public static float[] mMinRadius;

		public static float[] mMaxRadius;


		public static void start(string path)
        {
			tempP = path;
			ReadConfig();
		}

		public static void ReadConfig()
		{
			XmlDocument xmlDocument = new XmlDocument();
			XmlReaderSettings xmlReaderSettings = new XmlReaderSettings();
			xmlDocument.Load(XmlReader.Create(tempP + "/config.xml", xmlReaderSettings));
			XmlNodeList childNodes = xmlDocument.SelectSingleNode("Config").ChildNodes;
			foreach (XmlElement item in childNodes)
			{
		
				if (item.GetAttribute("id") == "1")
				{
					foreach (XmlElement childNode in item.ChildNodes)
					{
						if (childNode.Name.Equals("maxr"))
						{
							maxRadius = float.Parse(childNode.InnerText);
						}
						else if (childNode.Name.Equals("minr"))
						{
							minRadius = float.Parse(childNode.InnerText);
						}
						else if (childNode.Name.Equals("trueRadius"))
						{
							trueRadius = float.Parse(childNode.InnerText);
						}
						else if (childNode.Name.Equals("scale"))
						{
							uiScale = float.Parse(childNode.InnerText);
						}
						else if (childNode.Name.Equals("notime"))
						{
							checkNoTime = float.Parse(childNode.InnerText);
						}
						else if (childNode.Name.Equals("touch"))
						{
							checkTouch = childNode.InnerText == "1";
						}
						else if (childNode.Name.Equals("outputlog"))
						{
							outputlog = childNode.InnerText == "1";
						}
						else if (childNode.Name.Equals("maxangle"))
						{
							maxangle = childNode.InnerText == "1";
						}
						else if (childNode.Name.Equals("time"))
						{
							time = childNode.InnerText == "1";
						}
					}
				}
				else
				{
					if (!(item.GetAttribute("id") == "2"))
					{
						continue;
					}
					foreach (XmlElement childNode2 in item.ChildNodes)
					{
						try
						{
							circleID[int.Parse(childNode2.InnerText) - 1] = int.Parse(childNode2.InnerText);
							string[] array = childNode2.GetAttribute("angle1").Split('|');
							if (array != null && array.Length == 2)
							{
								angleA1[int.Parse(childNode2.InnerText) - 1] = float.Parse(array[0]);
								angleA2[int.Parse(childNode2.InnerText) - 1] = float.Parse(array[1]);
							}
							array = childNode2.GetAttribute("angle2").Split('|');
							if (array != null && array.Length == 2)
							{
								angleB1[int.Parse(childNode2.InnerText) - 1] = float.Parse(array[0]);
								angleB2[int.Parse(childNode2.InnerText) - 1] = float.Parse(array[1]);
							}
							array = childNode2.GetAttribute("angle3").Split('|');
							if (array != null && array.Length == 2)
							{
								angleC1[int.Parse(childNode2.InnerText) - 1] = float.Parse(array[0]);
								angleC2[int.Parse(childNode2.InnerText) - 1] = float.Parse(array[1]);
							}
							string attribute = childNode2.GetAttribute("specialangle");
							if (attribute != null && attribute.Length > 0)
							{
								try
								{
									specialAngle[int.Parse(childNode2.InnerText) - 1] = float.Parse(attribute);
								}
								catch (Exception)
								{
									specialAngle[int.Parse(childNode2.InnerText) - 1] = -1f;
								}
							}
							else
							{
								specialAngle[int.Parse(childNode2.InnerText) - 1] = -1f;
							}
							mMinRadius[int.Parse(childNode2.InnerText) - 1] = float.Parse(childNode2.GetAttribute("minradius"));
							mMaxRadius[int.Parse(childNode2.InnerText) - 1] = float.Parse(childNode2.GetAttribute("maxradius"));
						}
						catch (Exception)
						{
						}
					}
				}
			}
		}
	}
	


}